package com.sscaipiao.android.activity.ThreeD;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.sscaipiao.android.R;
import com.sscaipiao.android.activity.Base.BaseUIActivity;
import com.sscaipiao.android.activity.Base.BaseUIListActivity;
import com.sscaipiao.android.common.Constants;
import com.sscaipiao.android.utils.CaipiaoServiceHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ppona_000 on 14-1-4.
 */
public class SanDListActivity extends BaseUIListActivity implements AdapterView.OnItemClickListener {
	protected String date;
	protected String leftTime;

	private List<Map<String, Object>> mList;
	private ListView mListView;
	private String[] items = {
			"3D直选",
			"3D组三",
			"3D组六",
			"3D组三和值",
			"3D组六和值",
//			"",
//			"",
//			"",

	};

	private String[] mFrom = new String[]{"name"};
	private int[] mTo = new int[]{
			R.id.text1,
	};

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addContainerMain(R.layout.san_d_list_activity);
		//setContentView(R.layout.san_d_list_activity);
		mListView = (ListView) findViewById(R.id.item_list);
		mList = new ArrayList<Map<String, Object>>();
		for (int i = 0; i < items.length; i++) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("name",items[i]);
			mList.add(map);
		}

		SimpleAdapter mAdapter = new SimpleAdapter(this, mList,
				R.layout.simple_list_item,
				mFrom, mTo);

		mListView.setAdapter(mAdapter);
		mListView.setOnItemClickListener(this);
		setTitleText("3D");
		setLottInformation(getIntent());
	}
	public void setLottInformation(Intent intent) {
		if (!intent.equals(null)) {
			Bundle bundle = intent.getExtras();
			if (bundle == null) {
				return;
			}
			if (bundle.containsKey("date")) {
				date = (String) bundle.get("date");
			}
			if (bundle.containsKey("leftTime")) {
				leftTime = (String) bundle.get("leftTime");
			}
		}
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		Intent mi = new Intent();
		Class name = null;
		switch (position) {
			case 0:
				name = SanDZhiXuanActivity.class;
				break;
			case 1:
				name = SanDZuSanActivity.class;
				break;
			case 2:
				name = SanDZuLiuActivity.class;
				break;
			case 3:
				name = SanDZuSanHeZhiActivity.class;
				break;
			case 4:
				name = SanDZuLiuHeZhiActivity.class;
				break;
		}
		if (name != null) {
			Intent intent = new Intent(this, name);
			Bundle b = new Bundle();
			b.putSerializable("date",date);
			b.putSerializable("leftTime", leftTime);
			intent.putExtras(b);
			startActivity(intent);
		}
	}
}